﻿using AutomaticPush.Extension;
using AutomaticPush.Quartz;
using AutoPushExt.BLL;
using Quartz;

namespace AutomaticPush.Job.DaZhang
{
    /// <summary>
    /// 大张推送任务
    /// </summary>
    [QuartzRepeat(500, 0, true, 1)]
    [DisallowConcurrentExecution]
    public class DZPushOrderJob : AutoJob
    {

        public override async Task<Task> Execute(IJobExecutionContext context)
        {
            if (configs.PushType != 7)
            {
                Dispose();
                return Task.CompletedTask;
            }
            FromMessage($"{context.FireTimeUtc} DZPushOrderJob任务开始");
            LogHelper.WriteLog("DZPushOrderJob", $"{context.FireTimeUtc} DZPushOrderJob任务开始");
            try
            {

                DazhangBLL dazhangBLL = new DazhangBLL();
                await dazhangBLL.PushOrderReceive();
            }
            catch (Exception ex)
            {
                FromMessage($"{ex.Message} DZPushOrderJob任务结束异常");
                LogHelper.WriteLog("DZPushOrderJob", ex.Message);
            }
            FromMessage($"{context.FireTimeUtc} DZPushOrderJob任务结束");
            LogHelper.WriteLog("DZPushOrderJob", $"{context.FireTimeUtc} DZPushOrderJob任务结束");
            Dispose();
            return Task.CompletedTask;
        }
    }
}
